package com.shyt.impl.batch;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;

public class BaseServiceImpl<M extends BaseMapper<T>,T> extends ServiceImpl<M,T> implements BaseService<T>{

    private static final int DEFAULT_BATCH_SIZE = 1000;

    /***
     * 批量插入
     * @param collections 集合List
     * @return 返回boolean
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertBatch(Collection<T> collections) {
        return saveBatch(collections,DEFAULT_BATCH_SIZE);
    }
}
